package dtd.PHS.VND_ExchangeRate.data;

public class ListRatesCache {

	private static final long LIMIT_CACHE_TIME = 1*60*60*1000;
	
	private static long createdTime;
	private static ListRates cachedListRates = null;
	private static MyDate date = null;

	public static MyDate getDate() {
		return date;
	}

	public static void setDate(MyDate date) {
		ListRatesCache.date = date;
	}

	public static boolean isCached() {
		if ( cachedListRates == null) return false;
		if ( expired() ) return false;
		return true;
	}

	static boolean expired() {
		long now = System.currentTimeMillis();
		if ( now - createdTime > LIMIT_CACHE_TIME ) 
			return true;
		return false;
	}

	public static ListRates getListRates() {
		return cachedListRates;
	}

	public static void cacheListRates(ListRates rates) {
		cachedListRates = rates;
	}

	public static void setCreatedTime(long ctime) {
		createdTime = ctime;
	}

}
